﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web.Mvc;
using System.Web.WebPages;
using BL.Membership;

namespace System.Web.Mvc
{
    public static class AuthorizeWebExtensions
    {
        public static HelperResult Perms(this HtmlHelper html, Func<dynamic, HelperResult> template, params UserPermission[] perms)
        {
            return new HelperResult(writer =>
            {
                if (!new OrderDeskMembership().IsCurrentUserAllowed(perms))
                    return;

                template("").WriteTo(writer);
            });
        }
    }
}
